package pl.mikei.deliverydroid;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class SelectRestaurantActivity extends Activity 
	implements OnItemClickListener {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        ListView restaurants = (ListView)findViewById(R.id.restaurant);
        restaurants.setAdapter(new ArrayAdapter<String>(
        		this,
        		R.layout.menu_item,
        		getResources().getStringArray(R.array.restaurants)));
        
        restaurants.setOnItemClickListener(this);
    }

	@Override
	public void onItemClick(AdapterView<?> parent, View item, int position, long id) {
		switch(position) {
		case 0:
			startActivity(new Intent(this, TheBurgerPlaceActivity.class));
			break;
		case 1:
			startActivity(new Intent(this, TimerActivity.class));
		}
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.timer_menu, menu);
		return true;
		
	}
	
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
			case R.id.item_about:
				return super.onOptionsItemSelected(item);
			case R.id.item_exit:
				this.finish();
				return true;
			default: return super.onOptionsItemSelected(item);
		}
		
	}
    
}